//配置路由的地方
import Vue from "vue";
// 引入路由组件
import VueRouter from "vue-router";
// 使用路由插件
Vue.use(VueRouter);
// 引入路由组件
import ClubIndex from "@/views/ClubIndex/ClubIndex";
import ClubActivity from "@/views/ClubActivity/ClubActivity";
import ClubNotice from "@/views/ClubNotice/ClubNotice";
import ClubLists from "@/views/ClubLists/ClubLists";
import UserLogin from "@/views/UserLogin/UserLogin";
import AdviceList from "@/views/AdviceList/AdviceList";

//保存VueRouter.prototype.push
let originPush = VueRouter.prototype.push;
let originReplace = VueRouter.prototype.replace;

// 重写push和replace
VueRouter.prototype.push = function (location, resolve, reject) {
  if (resolve && reject) {
    originPush.call(this, location, resolve, reject);
  } else {
    originPush.call(
      this,
      location,
      () => {},
      () => {}
    );
  }
};
VueRouter.prototype.replace = function (location, resole, reject) {
  if (resole && reject) {
    originReplace.call(this, location, resole, reject);
  } else {
    originReplace.call(
      this,
      location,
      () => {},
      () => {}
    );
  }
};
//创建并暴露
export default new VueRouter({
  mode: "history",
  routes: [
    {
      path: "/ClubIndex",
      name: "ClubIndex",
      component: ClubIndex,
    },
    {
      path: "/ClubActivity",
      name: "ClubActivity",
      component: ClubActivity,
    },
    {
      path: "/ClubNotice",
      name: "ClubNotice",
      component: ClubNotice,
    },
    {
      path: "/ClubLists",
      name: "ClubLists",
      component: ClubLists,
    },
    {
      path: "/UserLogin",
      name: "UserLogin",
      component: UserLogin,
    },
    {
      path: "/AdviceList",
      name: "AdviceList",
      component: AdviceList,
    },
    {
      path: "/",
      redirect: "/ClubIndex",
    },
  ],
});
